
<style type="text/css">
/* For form validation message
* { font-family: Verdana; font-size: 96%; }
label { width: 10em; float: left; }
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
p { clear: both; }
.submit { margin-left: 12em; }
em { font-weight: bold; padding-right: 1em; vertical-align: top; }
*/
</style>

<?php
	$buttonLabel = "Create Goal";
	$projectXid = "new";
	if ( isset($project->sid)) { 
		$buttonLabel = "Update";
		$projectXid = $project->sid;
	} else {
		echo '<h3>New Goal</h3>';
	}
?>
	
		<form class="form-horizontal validating-form" name="ProjectForm" action="<?php echo controller_base_path($requestContext); ?>/Project/<?php echo $projectXid ?>/form" method="POST" enctype="multipart/form-data"   >
<?php if ( isset($project->sid)) {  ?>
			<input type="hidden" id="sid" name="sid" value="<?php echo $project->sid; ?>" />
			<input type="hidden" id="id" name="id" value="<?php echo $project->id; ?>" />
<?php } ?>
			<input type="hidden" id="domainId" name="domainId" value="<?php echo $project->domainId; ?>" />
		<fieldset>
			<legend>Enter information about your goal</legend>
			<div class="control-group">
				<label class="control-label" for="name">Name</label>
				<div class="controls">
					<input type="text" id="name" name="name" class="required"
						value="<?php echo Util_Data::getValueOf($project, 'name'); ?>" />
				</div>
			</div>
			
			<div class="control-group">
				<label class="control-label" for="profileImage">Profile picture</label>
				<div class="controls">
					<input type="file" id="profileImage" name="profileImage" 
						   value="" />
				</div>
			</div>
			
			<div class="control-group">
				<label class="control-label" for="goal" >Goal Description</label>
				<div class="controls">
					<textarea id="goal" name="goal" class="required" ><?php echo Util_Data::getValueOf($project, 'goal'); ?></textarea>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="description">Further description</label>
				<div class="controls">
					<textarea id="description" name="description" ><?php echo Util_Data::getValueOf($project, 'description'); ?></textarea>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="tagNamesCsv">Tags</label>
				<div class="controls">
					<input id="tagNamesCsv" name="tagNamesCsv" class="tags" 
						   value="<?php echo Util_Data::getValueOf($project, 'tagNamesCsv'); ?>" />
				</div>
			</div>

			<div class="control-group">
				<label class="control-label" for="categorySid">Category</label>
				<div class="controls">
					<?php echo Form::select('categorySid', $ref_categories, Util_Data::getValueOf($project, 'categorySid')); ?>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="planStartDate" >Start Date</label>
				<div class="controls">
					<input type="text" id="planStartDate" name="planStartDate" class="datepicker required" data-date-format="<?php echo $sessionInfo->userInfo['dateFormatJs']; ?>" 
						value="<?php echo datetime_format_convert(Util_Data::getValueOf($project, 'planStartDate'), FORMAT_DATE_ISO, $sessionInfo->userInfo['dateFormat']); ?>" />
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="planEndDate" >End Date</label>
				<div class="controls">
					<input type="text" id="planEndDate" name="planEndDate" class="datepicker required" data-date-format="<?php echo $sessionInfo->userInfo['dateFormatJs']; ?>" 
						value="<?php echo datetime_format_convert(Util_Data::getValueOf($project, 'planEndDate'), FORMAT_DATE_ISO, $sessionInfo->userInfo['dateFormat']); ?>"  />
				</div>
			</div>
			
			<div class="control-group">
				<label class="control-label" for="requiredSkillTagNamesCsv">Required Skills</label>
				<div class="controls">
					<input id="tagNamesCsv" name="requiredSkillTagNamesCsv" class="tags"
							value="<?php echo Util_Data::getValueOf($project, 'requiredSkillTagNamesCsv'); ?>"/>
				</div>
			</div>

			<div class="control-group">
				<div class="controls">
					<button type="submit" class="btn"><?php echo $buttonLabel ?></button>
				</div>
			</div>

		</fieldset>
	</form>

	<a href="<?php echo controller_base_path($requestContext); ?>/Project/<?php echo $project->sid; ?>/milestones">Update Milestones</a>
	
<script src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js" type="text/javascript" ></script>
<script type="text/javascript">
// FYI jQuery: multiple $(document).ready() is possible.
$(document).ready(function() {
	$('.datepicker').datepicker();
	$(".validating-form").validate();
	$('.tags').tagsInput({
		'height':'40px',
		'width':'300px'});

});
</script>